package org.yxing.palpalgps.domain;

public class UserInfo {
    public static final String KEY_ID = "id";
    public static final String KEY_FID = "id";
    public static final String KEY_NAME = "name";
    public static final String KEY_EMAIL = "email";
    public static final String KEY_GENDER = "gender";
    public static final String KEY_FACE = "picture";
    public static final String KEY_BIRTHDAY = "birthday";
    public static final String KEY_SESSION = "session";
    public static final String KEY_TOKEN = "access_token";
    public static final String KEY_EXPIRES = "access_expires";
    public static final String KEY_INTEREST = "interest";
    public static final String KEY_SEEK_GENDER = "seek_gender";
    public static final String KEY_SEEK_AGE = "seek_age";
    public static final String KEY_SEEK_AIM = "seek_aim";
    public static final String KEY_SEEK_DETAIL = "seek_detail";
    
    public static final String KEY_RELATION = "relation";
    public static final String KEY_CHAT_PASSWORD = "password";
    
    private String id;
    
    //facebook id
    private String fid;
    
    private String token;

	private String name;
	
	private String email;
	
	private String gender;
    
    private String session;
    
    private String face;
    
    private String birthday;
    
    private String chatPassword;
    
    private String interest;
    
    private String seekGender;
    
    private int seekAgeMin;
    
    private int seekAgeMax;
    
    private String seekAim;
    
    private String seekDetail;

    private int relation = 0;
    
    public UserInfo() {
    }
    
    public UserInfo(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public String getSession() {
        return session;
    }

    public void setSession(String session) {
        this.session = session;
    }
    
    public String getFid() {
		return fid;
	}

	public void setFid(String fid) {
		this.fid = fid;
	}
	
	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}
	
	public void setGender(String gender) {
	    this.gender = (gender.toLowerCase().startsWith("m")) ? "m": "f";
	}
	
	public String getGender() {
	    return gender;
	}
	
	public void setFace(String face) {
	    this.face = face;
	}
	
	public String getFace() {
	    return face;
	}
	
	public void setBirthday(String birthday) {
	    this.birthday = birthday;
	}
	
	public String getBirthday() {
	    return birthday;
	}
	
	public int getRelation() {
	    return relation;
	}
	
	public void setRelation(int relation) {
	    this.relation = relation;
	}
	
	public void setRelation(String relation) {
        this.relation = (relation == null || relation.length() < 5) ? 0 : Integer.parseInt(relation);
	}

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getChatPassword() {
        return chatPassword;
    }

    public void setChatPassword(String chatPassword) {
        this.chatPassword = chatPassword;
    }

    public String getInterest() {
        return interest;
    }

    public void setInterest(String interest) {
        this.interest = interest;
    }
	
    
    public String getSeekGender() {
        return seekGender;
    }

    public void setSeekGender(String seekGender) {
        this.seekGender = seekGender;
    }

    public int getSeekAgeMin() {
        return seekAgeMin;
    }

    public void setSeekAgeMin(int seekAgeMin) {
        this.seekAgeMin = seekAgeMin;
    }

    public int getSeekAgeMax() {
        return seekAgeMax;
    }

    public void setSeekAgeMax(int seekAgeMax) {
        this.seekAgeMax = seekAgeMax;
    }
    
    public void setSeekAge(String age) {
        String[] ages = age.split(",");
        if (ages.length == 2) {
            if (ages[0] != "") {
                setSeekAgeMin(Integer.parseInt(ages[0]));
            }
            if (ages[1] != "") {
                setSeekAgeMax(Integer.parseInt(ages[1]));
            }
        }
    }
    
    public String getSeekAge() {
        StringBuilder builder = new StringBuilder();
        if (seekAgeMin > 0) {
            builder.append(seekAgeMin);
        }
        builder.append(",");
        if (seekAgeMax > 0) {
            builder.append(seekAgeMax);
        }
        
        return builder.toString();
    }

    public String getSeekAim() {
        return seekAim;
    }

    public void setSeekAim(String seekAim) {
        this.seekAim = seekAim;
    }

    public String getSeekDetail() {
        return seekDetail;
    }

    public void setSeekDetail(String seekDetail) {
        this.seekDetail = seekDetail;
    }
}
